<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .active{
            text-decoration: underline;
        }
        .disabled{
            cursor: not-allowed;
        }
    </style>
</head>
<body>
    <div id="app">
        <div>当前是第{{cutPage}}页</div>
        <button
        v-bind:disabled="cutPage==1"
        v-on:click="change('-')"
        :class="{disabled:cutPage==1}"
        >上一页</button>
        <button v-for="num in 5"
         v-on:click="change(num)"
         v-bind:class="{active:num == cutPage}">
         {{num}}</button>
        <button
        :disabled="cutPage==5"
        v-on:click="change('+')"
        :class="{disabled:cutPage==5}"
        >下一页</button>
    </div>
    <script src="./vue.js"></script>
    <script>
        let vm = new Vue({
            el:'#app',
            data:{
                cutPage:1
            },
            methods:{
                change(flag){
                    if(flag == '+' && this.cutPage<5){
                        this.cutPage++;
                    }else if (flag == '-' && this.cutPage>1) {
                        this.cutPage--;
                    }else if (flag>0) {
                        this.cutPage = flag;
                    }
                }
            }
        })
    </script>
</body>
</html>